Fandt noget som måske kan bruges på php.net under str_replace
function replaceUrl($message) {
// Make link from [url]htp://.... [/url] or [url=http://.... ]text[/url]
while(strpos($message, "[url")!==false){
$begUrl = strpos($message, "[url");
$endUrl = strpos($message, "[/url]");
$url = substr($message, $begUrl, $endUrl-$begUrl+6);
$posBracket = strpos($url, "]");
if ($posBracket != null){
if ($posBracket == 4){
// [url]http://.... [/url]
$link = substr($url, 5, $endUrl - $begUrl -5);
$htmlUrl = "<a href=$link target='_blank'>$link</A>";
} else {
// [url=http://....]text[/url]
$link = substr($url, 5, $posBracket-5);
$text = substr($url, $posBracket+1, strpos($url, "[/url]") - $posBracket-1);
$htmlUrl = "<a href=$link target='main'>$text</A>";
}
}
$message = str_replace($url, $htmlUrl, $message);
// searches for other [url]-nodes
}
return $message;
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GED d- s: a--- C++ U? P L+ E? W++ N? o? K- w
O? M? V? PS PE? Y? PGP++ t 5? X+ R tv+ b+ DI? D+
G e-- h! !r y--
------END GEEK CODE BLOCK------